var arr=[1,2,3,4,2,5,6,2,7,2];
var arr1=[];
for(e of arr){
    if(e!==2){
        arr1.push(e)
    }
}
console.log(arr1);